from database import *
from flask import Flask, g
from flask import abort
from flask import request
from flask import Blueprint, current_app
import json
from utils import get_real_addr
from sqlalchemy import desc

LOG = config.getlogger()

install = Blueprint('install', __name__)


@install.route('/', methods=['GET'])
@install.route('/<uname>', methods=['GET'])
def get_usermap(uname=None):
    ret = {}
    query_result = db_session.query(InstallUserMap)
    if uname is not None:
        query_result = query_result.filter(InstallUserMap.uname == uname)
    for item in query_result.all():
        ret[item.uname] = item.uid
    return json.dumps(ret)
